#include <string>
#include <sstream>
#include <vector>

using namespace std;
string simplifyPath(string path)
    {
        stringstream ss(path);
        string part = "";
        vector<string> stackStr;
        while(getline(ss,part,'/'))
        {
            if(part == "." || part.empty())
            {
                continue;
            } else if(part == "..")
            {
                if(!stackStr.empty())
                {
                    stackStr.pop_back();
                }
            } else{
                stackStr.push_back(part);
            }
        }

        string result = "/";
        for(auto begin = stackStr.begin();begin != stackStr.end();begin++)
        {
            result += *begin;
            if(begin != stackStr.end() - 1)
            {
                result += "/";
            }
        }
        return result;
    }   